package priv.books.service;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import priv.books.mapper.SaleMapper;
import priv.books.pojo.Sale;
@Service
public class SaleService extends ServiceImpl<SaleMapper, Sale> {

    @Autowired
    private SaleMapper saleMapper;

    public List<Sale> getAllInfo(Sale sale) {
        QueryWrapper<Sale> queryWrapper = new QueryWrapper<Sale>();
        queryWrapper.ge(!StrUtil.isBlankOrUndefined(sale.getStartTime()), "create_date", sale.getStartTime() + " 00:00:00");
        queryWrapper.le(!StrUtil.isBlankOrUndefined(sale.getEndTime()), "create_date", sale.getEndTime() + " 23:59:59");
        return saleMapper.selectList(queryWrapper);
    }

    public List<Map<String, Object>> getBooksSale(Sale sale) {
        return saleMapper.getBooksSale(sale);
    }
}
